<template>
    <div class="dome">
        <h2>学校名称：{{schoolName}}</h2>
        <h2>学校地址：{{address}}</h2>
    </div>
</template>

<script>
export default {
    name:'School',
    data() {
        return {
            schoolName:'尚硅谷',
            address:'深圳'
        }
    },    
    mounted() {
        this.$bus.$on('hello',(date)=>{
            console.log("我是school组件，我收到数据了",date)
        })
    },
    // 在实例对象销毁前把全局自定义事件关闭
    beforeDestroy(){
        this.$bus.$off('hello')
    }
}
</script>

<style>
    .dome{
        background-color:grey;
        margin: 30px 0;
    }
</style>